package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Api(tags = "文章相关接口")
public class ArticleHomeController {

    @Autowired
    private ApArticleService apArticleService;

    /**
     * 首页展示
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation("首页展示")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,articleHomeDto);
    }

    /**
     * 加载更多
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadmore")
    @ApiOperation("加载更多")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto articleHomeDto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,articleHomeDto);
    }

    /**
     * 刷新
     * @param articleHomeDto
     * @return
     */
    @PostMapping("/loadnew")
    @ApiOperation("刷新")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto articleHomeDto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,articleHomeDto);
    }
}
